// geometry.ts  
import PipelineObject from '../interface/pipelineObject';
import { IGeometry } from '../interface/geometry';
 
export default class Geometry implements IGeometry {
    public vertex: Float32Array;
    public index: Uint16Array | Uint32Array;
    public vertexCount: number;
    public indexCount: number;
    public pipeline: PipelineObject;
 
    constructor(
        vertex: Float32Array, 
        index: Uint16Array | Uint32Array, 
        vertexCount: number, 
        indexCount: number, 
        pipeline: PipelineObject) {
        this.vertex = vertex;
        this.index = index;
        this.vertexCount = vertexCount;
        this.indexCount = indexCount;
        this.pipeline = pipeline;
    }
 
    // 可以添加其他方法来操作顶点和索引数据
    public getVertexData(): Float32Array {
        return this.vertex; 
    }
 
    public getIndexData(): Uint16Array | Uint32Array {
        return this.index; 
    }
 
    public setVertexData(vertex: Float32Array): void {
        this.vertex = vertex;
        this.vertexCount = vertex.length  / 8; // 假设每个顶点有8个分量 (position: 3, normal: 3, uv: 2)
    }
 
    public setIndexData(index: Uint16Array | Uint32Array): void {
        this.index = index;
        this.indexCount  = index.length; 
    }
}